//student 页面获取数据、删除数据、添加数据  、修改数据
import Mock from 'mockjs'
var List = []
const Mock1 = require('mockjs')
for (var i = 0; i < 400; i++) {
    Mock1.Random.extend({
        phone: function () {
            var phonePrefixs = ['132', '135', '189'] // 自己写前缀哈
            return this.pick(phonePrefixs) + Mock1.mock(/\d{8}/) //Number()
        }
    })
    //   console.log(Mock1.Random.phone())
    //   let { phone } = Mock1.mock({
    //     'phone|1-10': ['@phone']
    //   })
    //   console.log(phone);
    List.push({
        ID: Mock.mock('@id()'),
        name: Mock.mock('@cname()'),
        phone: Mock1.Random.phone(),
        price: Mock.mock('@integer(1000, 3000)'),
        number: Mock.mock('@integer(1, 10)'),
        vip: Mock.mock('@integer(1, 3)'),
        date: Mock.mock('@date'),
        disable: false,
        address: Mock.mock('@county(true)'),
    })
}
export default {
    getData: config => {
        return {
            code: 200,
            msg: '查询成功',
            data: List
        }
    },
    deletData: conf => {
        const { id } = JSON.parse(conf.body)
        for (var i = 0; i < List.length; i++){
            if(List[i].ID == id ){
                // console.log(111);
                List.splice(i,1)
            }
        }
            // console.log('conf', conf);
        return {
            code: 200,
            msg: '删除成功',
            data: null
        }
    }
}